#include "CLambda.h"
#include "CEventSystem.h"
#include "SGD Wrappers\CSGD_TextureManager.h"
CLambda::CLambda()
{
	CEventSystem::GetInstance()->RegisterClient("MoveUp",this);
	CEventSystem::GetInstance()->RegisterClient("MoveDown",this);
	CEventSystem::GetInstance()->RegisterClient("MoveLeft",this);
	CEventSystem::GetInstance()->RegisterClient("MoveRight",this);
	CAnimationManager::GetInstance()->FindAnim("YoumuStand",&anim);
	scale = 1;
}

CLambda::~CLambda()
{
	CEventSystem::GetInstance()->UnregisterClient("MoveUp",this);
	CEventSystem::GetInstance()->UnregisterClient("MoveDown",this);
	CEventSystem::GetInstance()->UnregisterClient("MoveLeft",this);
	CEventSystem::GetInstance()->UnregisterClient("MoveRight",this);
}
void CLambda::Update(float fElapsedTime)
{
	CAnimationManager::GetInstance()->Update(&anim,fElapsedTime);
	SetPosX(GetPosX() + (GetVelX() * fElapsedTime));
	SetPosY(GetPosY() + (GetVelY() * fElapsedTime));
	SetVelX(0);
	SetVelY(0);
}
void CLambda::Render()
{
	CAnimationManager::GetInstance()->Render(&anim,GetPosX(),GetPosY(),scale,0,false,D3DCOLOR_XRGB(255, 255, 255));

}
void CLambda::HandleEvent(CEvent* pEvent)
{
	if(pEvent->GetEventID() == "MoveUp")
	{
		 
	}
	else if(pEvent->GetEventID() == "MoveDown")
	{
		 
	}
	else if(pEvent->GetEventID() == "MoveRight")
	{
		SetVelX(30);
		CAnimationManager::GetInstance()->FindAnim("YoumuWalk",&anim);
	}
	else if(pEvent->GetEventID() == "MoveLeft")
	{
		SetVelX(-30);
	}
}